<? 
	$title="Edit category"; 
	$pageid="5";
	$accessid="a00";

	require("required/dbconnect.php"); 
	require("required/header.php");
	require("required/function.php");
	checkAccess("allow_product_category",1);
	
	$id=$_GET['id'];
	
	$get_info=mysql_query("select * from os_sub_category where id=$id");
	
	if(mysql_num_rows($get_info)==0)
	{
		echo "No record found!!";
	}
	else
	{
		

	$a=mysql_fetch_array($get_info,MYSQL_ASSOC);
	 if ($a['is_publish'] == 0) {
            $slt0 = "selected";
            $slt1 = "";
        } else {
            $slt0 = "";
            $slt1 = "selected";
        }
?>
<script src="required/js/jquery-1.4.2.js"></script>
<script src="required/js/common_javascript.js"></script>
<script language="JavaScript" type="text/javascript" src="required/js/goAjax.js"></script>
<?	
	
	if(!empty($_GET['action']))
	{
		switch($_GET['action'])
		{
			case 1:
				$msg="<div class='dw_success'>Data inserted</div>";
				break;
			case 2:
				$msg="<div class='dw_success'>Data Deleted</div>";
				break;
			case 3:
				$msg="<div class='dw_success'>Data Updated</div>";
				break;
			case 4:
				$msg="<div class='dw_failed'>Category Name already exist, update failed!</div>";
				break;		
			default:
				$msg="";
				break;
		}
		echo "<script>displayMsg('divMsg')</script>";	
	}else{
		$msg="";
	}
	
	
	
?>

<table width="100%" cellpadding="2" cellspacing="1">
	
	<td valign="top">
	<table width="100%">
	<tr>
		<td colspan="4" class="title">Edit Category</td>
	</tr>
      <tr>
    	<Td colspan="3" align="left">  <div id="divMsg"><?= $msg ?></div></Td>
    </tr>
	<form action="subcat_edit2.php" method="post" name="frm" onSubmit="return frmValidate(this)">
	<input type="hidden" value="<?= $id ?>" name="id">
	<?
		$get_cat=mysql_query("select * from os_category order by id asc");
		
	
	?>
	<tr>
		<Td width="17%">Main Category</Td><td>:</td>
		<td width="82%">
			<select name="main_cat" class="text">
			<?
				while($c=mysql_fetch_array($get_cat,MYSQL_ASSOC))
				{
					if($c['id']==$a['main_category'])
					{
						$slt="selected";
					}
					else
					{
						$slt="";
					}
			?>
				<option value="<?= $c['id'] ?>" <?= $slt ?>><?= $c['name_chn'] ?> <?= $c['name_eng'] ?></option>
			<? } ?>
			</select>
			
		</td>
	</tr>
	<tr>
		<td width="17%">Category</td><td width="1%">:</td><td width="82%"><input type="text" size="30" name="name_eng" class="text" value="<?= $a['name_eng'] ?>">
        <input type="hidden" value="<?= $a['main_category'] ?>" name="current_main_cat" />
        <input type="hidden" value="<?= $a['name_eng'] ?>" name="current_name_eng" />
        </td>
	</tr>
	<tr>
                        <td>Display</td><td>:</td><td>
                            <select name="is_publish">
                                <option value="1" <?= $slt1 ?>>Yes</option>
                                <option value="0" <?= $slt0 ?>>No</option>
                            </select>
                        </td>
                    </tr>

	
	
	<tr>
		<td colspan="4" align="center"><br><input type="submit" value="update" class="button">  <input type="button" value="Cancel" class="button" onclick="window.open('subcat_management.php','_self')"><br><br></td>
	</tr>
	</form>
	</table></td>
			
</table>
<? } require("required/footer.php"); ?>

